home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / bserverdir / sources / clients / shutscreen.c < prev    next >
C/C++ Source or Header  |  1994-11-29  |  4KB  |  170 lines

  1. ; /*
  2. sc shutscreen.c DATA=FAR NMINC STRMERGE NOSTKCHK IGNORE=73 STRUCTUREEQUIVALENCE NOSTDIO
  3. slink from lib:c.o shutscreen.o to //Clients/ShutScreen lib /lib/client.lib lib:sc.lib lib:amiga.lib SC SD STRIPDEBUG NOICONS
  4. delete shutscreen.o
  5. quit
  6.  
  7.  ShutScreen 1.2  (Client for BServer)
  8.  
  9.  Copyright © 1994 Stefano Reksten of 3AM - The Three Amigos!!!
  10.  All rights reserved.
  11. */
  12.  
  13. #include <intuition/intuition.h>
  14. #include <intuition/intuitionbase.h>
  15. #include <graphics/scale.h>
  16.  
  17. #include <clib/exec_protos.h>
  18. #include <clib/intuition_protos.h>
  19. #include <clib/graphics_protos.h>
  20.  
  21. #include "/include/client.h"
  22. #include "/include/bitmap/bitmap.h"
  23. #include "/include/bitmap/bitmap_pragmas.h"
  24.  
  25.  
  26. struct IntuitionBase *IntuitionBase;
  27. struct GfxBase *GfxBase;
  28. struct Library *BitMapBase;
  29.  
  30. struct Screen *clonescr, *scr;
  31. UWORD scrwidth, scrheight, scrdepth;
  32. ULONG command;
  33.  
  34. struct BitMap *bmap, *scalebmap;
  35. struct DisplayIDInformation *dinfo;
  36.  
  37. struct BitMapScaleInfo myscaleinfo = {
  38.     NULL, NULL, NULL, 1, 1, 0, 0,
  39.     0, 0, 0, 0, 0, 0, NULL };
  40.  
  41. void Shut( void )
  42. {
  43. BOOL still_blitting;
  44. BOOL blanking, success = FALSE;
  45. UWORD n, frame;
  46. ULONG color, darkest_color = 0xF, darkest_index = 0;
  47.  
  48. clonescr = IntuitionBase->FirstScreen;
  49. scrwidth = clonescr->Width;
  50. scrheight = clonescr->Height;
  51. scrdepth = clonescr->RastPort.BitMap->Depth;
  52.  
  53. if ( scalebmap = CreateBitMap( scrwidth, scrheight, scrdepth ) )
  54.     {
  55.     if ( bmap = CreateBitMap( scrwidth, scrheight, scrdepth ) )
  56.         {
  57.         BltBitMap( clonescr->RastPort.BitMap, 0, 0,
  58.             bmap, 0, 0, scrwidth, scrheight, 0xC0, 0xFF, NULL );
  59.  
  60.         myscaleinfo.bsi_SrcBitMap = clonescr->RastPort.BitMap;
  61.         myscaleinfo.bsi_TempBitMap = scalebmap;
  62.         myscaleinfo.bsi_DestBitMap = bmap;
  63.         myscaleinfo.bsi_Width = scrwidth;
  64.         myscaleinfo.bsi_Height = scrheight;
  65.         myscaleinfo.bsi_VertDen = scrheight;
  66.  
  67.         if ( scr = OpenScreenTags( NULL,
  68.             SA_Width, scrwidth,
  69.             SA_Height, scrheight,
  70.             SA_Depth, scrdepth,
  71.             SA_DisplayID, GetVPModeID( &clonescr->ViewPort ),
  72.             SA_BitMap, bmap,
  73.             SA_Overscan, OSCAN_TEXT,
  74.             TAG_END ) )
  75.             {
  76.             if ( scr->ViewPort.ColorMap = GetColorMap( 1<<scrdepth ) )
  77.                 {
  78.                 for ( n = 0; n < 1<<scrdepth; n++ )
  79.                     {
  80.                     color = GetRGB4( clonescr->ViewPort.ColorMap, n );
  81.                     if ( (color & 0xF0)>>4 < darkest_color )
  82.                         {
  83.                         darkest_color = (color & 0xF0)>>4;
  84.                         darkest_index = n;
  85.                         }
  86.                     SetRGB4( &scr->ViewPort, n, color >> 8, (color & 0xF0) >> 4, color & 0xF );
  87.                     }
  88.  
  89.                 ScreenToFront( scr );
  90.  
  91.                 success = TRUE;
  92.                 SpritesOff();
  93.  
  94.                 blanking = TRUE;
  95.                 still_blitting = TRUE;
  96.                 frame = 0;
  97.  
  98.                 SetAPen( &scr->RastPort, darkest_index );
  99.  
  100.                 while( blanking )
  101.                     {
  102.                     if ( still_blitting )
  103.                         command = GetServerCommand();
  104.                     else
  105.                         command = WaitServerCommand();
  106.  
  107.                     if ( command != COMMAND_IDLE )
  108.                         blanking = FALSE;
  109.                     else
  110.                     if ( still_blitting )
  111.                         {
  112.                         UWORD fr = frame>>1;
  113.  
  114.                         Move( &scr->RastPort, 0, fr );
  115.                         Draw( &scr->RastPort, scrwidth - 1, fr );
  116.                         Move( &scr->RastPort, 0, scrheight - fr - 1);
  117.                         Draw( &scr->RastPort, scrwidth - 1, scrheight - fr - 1 );
  118.                         frame += 2;
  119.                         if ( frame > scrheight )
  120.                             {
  121.                             SetAPen( &scr->RastPort, 0 );
  122.                             SetRGB4( &scr->ViewPort, 0, 0, 0, 0 );
  123.                             SetRast( &scr->RastPort, 0 );
  124.                             still_blitting = FALSE;
  125.                             }
  126.                         else
  127.                             {
  128.                             myscaleinfo.bsi_VertNum = scrheight - frame;
  129.                             myscaleinfo.bsi_DestTopEdge = frame>>1;
  130.                             ScaleBitMap( &myscaleinfo );
  131.                             }
  132.                         }
  133.                     }
  134.  
  135.                 SpritesOn();
  136.                 FreeColorMap( scr->ViewPort.ColorMap );
  137.                 }
  138.             CloseScreen( scr );
  139.             }
  140.         DisposeBitMap( bmap );
  141.         }
  142.     DisposeBitMap( scalebmap );
  143.     }
  144.  
  145. if ( !success )
  146.     SendClientMsg( ACTION_FAILED );
  147. }
  148.  
  149.  
  150. void __main( char *line )
  151. {
  152. if ( IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 36L ) )
  153.     {
  154.     if ( GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library",0L ) )
  155.         {
  156.         if ( BitMapBase = OpenLibrary( "bitmap.library", 0L ) )
  157.             {
  158.             if ( dinfo = OpenCommunication() )
  159.                 {
  160.                 Shut();
  161.                 CloseCommunication( dinfo );
  162.                 }
  163.             CloseLibrary( BitMapBase );
  164.             }
  165.         CloseLibrary( (struct Library *)GfxBase );
  166.         }
  167.     CloseLibrary( (struct Library *)IntuitionBase );
  168.     }
  169. }
  170.